﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FluentNHibernate.Mapping;

namespace Managistics.Model.Mappings
{
    public class CustomerMap : ClassMap<Customer>
    {

        public CustomerMap()
        {
            Schema(Constants._tblSchema);
            Table(Constants._tblCustomer);
            LazyLoad();

            Id(x => x.Code).GeneratedBy.Assigned().Column("CUSTOMERID");
            References(x => x.City).Column("CITYID");

            Map(x => x.Name).Column("CUSTOMERNAME").Not.Nullable().Length(500);
            Map(x => x.ContactPerson).Column("CONTACT_PERSON").Length(50);
            Map(x => x.Address).Column("ADDRESSCOMPANY").Length(150);
            Map(x => x.Email).Column("EMAILCOMPANY").Length(30);
            Map(x => x.Website).Column("WEBSITECOMPANY").Length(50);
            Map(x => x.Telephone).Column("TELEPHONE").Not.Nullable().Length(20);
            Map(x => x.Cellphone).Column("CELLPHONE").Length(20);
            Map(x => x.BankAccountC1).Column("BANK_ACCOUNT_C1").Length(100);
            Map(x => x.BankAccountC2).Column("BANK_ACCOUNT_C2").Length(100);
            Map(x => x.BankAccountC3).Column("BANK_ACCOUNT_C3").Length(100);
            Map(x => x.Taxcode).Column("TAXCODE").Length(20);
            Map(x => x.Fax).Column("FAX").Length(30);
            Map(x => x.Postcar).Column("POSTCAR").Length(15);
            Map(x => x.Status).Column("STATUS").Not.Nullable();
            Map(x => x.ExtendNumber).Column("EXTEND_NUMBER").Precision(10);
            Map(x => x.AddressDeliver1).Column("ADDRESS_DELIVER_1").Not.Nullable().Length(250);
            Map(x => x.AddressDeliver2).Column("ADDRESS_DELIVER_2").Length(250);
            Map(x => x.AddressDeliver3).Column("ADDRESS_DELIVER_3").Length(250);

            HasMany(x => x.ContactPersons).KeyColumn("CustomerID");
        }
    }
}
